﻿using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using SqlSugar;
using System.Web.Http;
using wnet.admin.dbhelper;
using ZR.Model.System;
using wnet.admin.Models;



namespace wnet.admin.Controllers.pcapi
{
    [Route("business/User/{action}")]
    public class sysuserController : ApiController
    {

        private readonly ISqlSugarClient _sqlSugarClient;
        public sysuserController()
        {
            _sqlSugarClient = SqlSugarConfig.CreateClient();
        }
        /// <summary>
        /// 获取
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public object list(UserQueryDto dto)
        {
           
            var exp = Expressionable.Create<SysUser>();
         
            exp.And(u => u.DelFlag == 0);
            var query = _sqlSugarClient.Queryable<SysUser>()
                .Where(exp.ToExpression())
                .Select((u) => new SysUser
                {
                    UserId = u.UserId.SelectAll(),

                });

            var datalist = query.ToPage(dto);

            var data = new { code = 200, msg = "成功", data = datalist };

            return Json(data, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });
        }




    }
}
